<h1>Invite respondents</h1>

<?php echo $this->validation->error_string; ?>
<?php echo form_open('respondents/invite_resp');?>
E-mail:<br />
<?php echo form_textarea(array('name' => 'invite_resp', 'cols' => '70', 'rows' => '10'), 'Insert e-mail/s here, separated by a comma'); ?>
<br />Invitation body:<br />

<input type="radio" id="template" name="mode" value="template"> Use an existing template</input><br/>
<input type="radio" id="custom" name="mode" value="custom"> Use a custom message</input><br/><br/>

<?php echo form_textarea(array('id' => 'body' , 'name' => 'welcome_message', 'style' => 'display:none', 'cols' => '70', 'rows' => '10'), 'Insert a welcome message'); ?>

<div id="loaded" style="display:none">
Templates: <br/>
<?php foreach($templates as $template)
{
	echo "<input type=\"radio\" name=\"loaded_templates\" value=\"$template\"> Use this template</input><br/><textarea readonly cols=70 rows=10> $template</textarea><br/><br/>";	
}

?>

</div>
<br /><br />
<?php echo form_submit('submit', 'Send invitation'); ?>  
<?php echo form_reset('reset', 'Reset'); ?>
<?php echo form_hidden('survey_id', $survey_id); ?>
<?php echo form_close(); ?>


<script src="<?php echo base_url(); ?>public/js/jquery.js"></script>
<script type="text/javascript">
	
	$(document).ready(function(){
		$("#template").change(function(){
			$("#body").hide('fast');
			$("#loaded").show('fast');
			
		});
		
		$("#custom").change(function(){
			$("#loaded").hide('fast');
			$("#body").show('fast');
			$("#body").val('Insert a welcome message');
		});
		
		$("input[name='loaded_templates']").change(function(){
				$("#body").val($("input[name='loaded_templates']:checked").val());
			});
	});
</script>
